// TaskStatusEnum.java
package com.ruoyi.system.domain.enums;

import lombok.Getter;

@Getter
public enum TaskStatusEnum {
    PENDING(0, "待执行"),
    EXECUTING(1, "执行中"),
    SUCCESS(2, "成功"),
    FAILED(3, "失败"),
    CANCELLED(4, "已取消");

    private final Integer code;
    private final String desc;

    TaskStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDescByCode(Integer code) {
        for (TaskStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status.getDesc();
            }
        }
        return "未知状态";
    }
}